/*
 * @Author: hongbin
 * @Date: 2022-11-25 11:37:38
 * @LastEditors: hongbin
 * @LastEditTime: 2022-11-25 22:03:24
 * @Description:
 */
import { ObjectId } from "mongodb";
import { NextApiRequest, NextApiResponse } from "next";
import DB from "../mongodb";

export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
    const db = await DB;
    const { id } = req.query;
    if (!id) return res.status(501).json({ code: -1, msg: "未传递参数id" });

    const find = {
        userId: new ObjectId(id as string),
    };

    const config = await db.collection("partsConfig").findOne(find);
    console.log("查询用户配件配置", config, id);

    res.json(config);
}
